<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            超市库存管理系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="./css/x-admin.css" media="all">
        
        <style>
        
        	div[class="layui-unselect layui-form-select"]{
        	    margin-bottom: 5px;
        	}
       
	       	input[placeholder="管理员"]{
	       		 padding-left: 30px;
	       	}
       
          
        
        </style>
    </head>
    
    <body style="background-color: #393D49">
        <div class="x-box">
            <div class="x-top">
                <i class="layui-icon x-login-close">
                    &#x1007;
                </i>
                <ul class="x-login-right">
                    <li style="background-color: #F1C85F;" color="#F1C85F">
                    </li>
                    <li style="background-color: #EA569A;" color="#EA569A">
                    </li>
                    <li style="background-color: #393D49;" color="#393D49">
                    </li>
                </ul>
            </div>
            <div class="x-mid">
                <div class="x-avtar">
                    <img src="./images/logo.png" alt="">
                </div>
                <div class="input">
                    <form class="layui-form" action="${pageContext.request.contextPath}/logins" id="login-id" method="post">
                    	<select name="purview">
                    		<option value="0">管理员</option>
                    		
                    		<option value="2">普通</option>
                	</select>
                        <div class="layui-form-item x-login-box">
                            <label for="username" class="layui-form-label">
                                用户名:
                            </label>
                            <div class="layui-input-inline">
                                <input type="text" id="username" name="username" required="" lay-verify="username"
                                autocomplete="off" class="layui-input" style="height: 30px;" />
                            </div>
                        </div>
                        <div class="layui-form-item x-login-box">
                            <label for="pass" class="layui-form-label">
                                密&nbsp;&nbsp;&nbsp;&nbsp;码
                            </label>
                            <div class="layui-input-inline">
                                <input type="password" id="pass" name="password" required="" lay-verify="pass"
                                autocomplete="off"  class="layui-input" style="height: 30px;" />
                            </div>
                        </div>
                       <div class="layui-form-item x-login-box">
                            <label for="username" class="layui-form-label">
                                验证码
                            </label>
                            <div class="layui-input-inline">
                                <input type="text" id="verifycode" name="yanma" required="" lay-verify=""
                                autocomplete="off" class="layui-input" style="height: 30px;width: 160px;"/>
                                <img src="${pageContext.request.contextPath}/VerifyCode" id="imgCode"
                                alt="看不清楚？请点击刷新验证码" onclick="javascript:reloadCode();"
                                class="yzm-img" style="margin-top: -58px;margin-left: 163px;"/>
                            </div>

    


                        </div> 
                        <div class="layui-form-item" id="loginbtn">
                           <input type="submit" class="layui-btn"  value="登 录" />		<!--  onclick="login()" -->
                                
                            
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <script type="./js/jquery-3.3.1.js"></script>
        <script>
        
        function reloadCode(){
            var time = new Date().getTime();
            document.getElementById("imgCode").src="<%=request.getContextPath() %>/VerifyCode?d=" + time;
            }
  
        function checkLoginNoNull() {
            if ($.trim($("#verifycode").val()) == "") {
                alert("验证码不能为空！请重新输入！");
                return false;
            }
        }
        
        function login() {
        	
        	
            
             $.post("${pageContext.request.contextPath}/logins",$("#login-id").serialize(),function(res){
            	
            	if(res.code == 200){
            		console.log(res.msg)
            		
            		window.location.href = "${pageContext.request.contextPath}/index";
            		
            	}else{
            		
            		console.log(res.error)
            		alert(res.error)
            		window.location.href = "${pageContext.request.contextPath}/login";
            	}
            	
            	
            }); 
            
        };
        </script>
        
        <script src="./lib/layui/layui.js" charset="utf-8">
        </script>
        <script>
        
        
        
            layui.use(['form'],
            function() {
                $ = layui.jquery;
                var form = layui.form(),
                layer = layui.layer;

                $('.x-login-right li').click(function(event) {
                    color = $(this).attr('color');
                    $('body').css('background-color', color);
                });

                //监听提交
                //form.on('submit(save)',
                

            });

        </script>
    </body>

</html>